<?php
$entity_count_first = $pages->getEntityCount() ? $pages->getPerPage() * ($page->getPageNumber() - 1) + 1 : 0;
$entity_count_last = ($pages->getEntityCount() < $entity_count_now = $pages->getPerPage() * $page->getPageNumber()) ? $pages->getEntityCount() : $entity_count_now;
$node_nav_result = __('Showing %1$d - %2$d of %3$d', array($entity_count_first, $entity_count_last, $pages->getEntityCount()));
?>
<div class="nodesBreadcrumb">
  <?php echo $this->helper('XiggBreadCrumb', $CONFIG);?><a href="<?php echo Sabai_URL::get('/tag');?>"><?php _e('Tags');?></a> &#8250; <?php _h(sprintf(_('Tag: %s'), $tag->getLabel()));?>
</div>
<div class="nodesHead clearfix">
  <ul>
<?php if ($CONFIG->get('useUpcomingFeature')):?>
    <li class="active"><?php _e('Popular news');?></li>
    <li>
      <a href="<?php echo Sabai_URL::get($route .'/upcoming');?>" title="<?php _e('Upcoming news');?>"><?php _h(sprintf(_('Upcoming news (%d)'), $upcoming_count));?></a>
    </li>
<?php else:?>
    <li class="active"><?php _e('News list');?></li>
<?php endif;?>
<?php if ($USER->isInRole(array(XIGG_ROLE_ADMIN, XIGG_ROLE_EDITOR, XIGG_ROLE_WRITER, XIGG_ROLE_SUBMITTER))):?>
    <li>
      <a href="<?php echo Sabai_URL::get('/submit');?>" title="<?php _e('Submit news');?>"><?php _e('Submit news');?></a>
    </li>
<?php endif;?>
  </ul>
  <h1 class="categoryTitle"><?php _h(sprintf(_('Tag: %s'), $tag->getLabel()));?></h1>
</div>
<div class="nodesFeed">
  <a href="<?php echo Sabai_URL::get('/rss' . $route);?>"><img src="<?php echo $LAYOUT_URL;?>/images/feed.png" width="16" height="16" alt="RSS feed" title="RSS feed" /></a>
</div>
<div class="nodesSearch">&nbsp;</div>
<table class="nodesNav">
  <tr>
    <td class="nodesNavResults"><?php echo $node_nav_result;?></td>
    <td class="nodesNavSort"><?php _e('Sort by: '); select_to_remote('period', $requested_period, 'xigg-main-shownodesbytag', $sorts, array('base' => $route), _('GO'));?></td>
  </tr>
</table>
<?php if (isset($nodes)):
        $nodes =& $nodes->with('Tags'); $nodes =& $nodes->with('User'); $nodes =& $nodes->with('Category'); $nodes->rewind();
        while ($node =& $nodes->getNext()):
          include $this->getTemplatePath('xigg_main_shownodesummary.html');
        endwhile;?>
<table class="nodesNav">
  <tr>
    <td class="nodesNavPages"><?php echo $this->helper('PageNavRemote', 'xigg-main-shownodesbytag', $pages, $page->getPageNumber(), array('base' => $route, 'params' => array('period' => $requested_period)));?></td>
  </tr>
</table>
<?php endif;?>